package com.example.demo.mapper;

import com.example.demo.admin.dto.RegisterDto;
import com.example.demo.admin.dto.SearchDto;
import com.example.demo.admin.pojo.User;
import com.example.demo.admin.vo.PageResultVo;
import com.example.demo.admin.vo.UserVo;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {
    //注册用户
    @Insert("insert into emp(username, name,password,dept_id,create_time, update_time,entrydate )" +
            "values (#{username},#{name},#{password},#{deptId},#{createTime},#{updateTime},#{entrydate})")
    void addUser( User user);

    @Select("select * from emp where username=#{username} and password=#{password}")
    User login(RegisterDto registerDto);
    @Select("select * from emp where username=#{username}")
    User exitUser(String username);

    @Select("select name,username,gender,job,image,dept_id from emp  where id=#{currentId}")
    UserVo getUserById(Long currentId);

    void updateUser(User user);

    Page<PageResultVo> getAllUser(SearchDto searchDto);

    @Delete("delete from emp where username =#{username}")
    void deleteUser(String username);

    Integer selectEveryMonths(String lastTime);

    @Update("update emp set job = NULL  where job=#{id}")
    void updateJob(Long id);

    @Update("update emp set dept_id = NULL  where dept_id=#{id}")
    void updateDept(Long id);
}

